# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Robin Krahl <robin.krahl@ireas.org>

pkgname=nitrocli
pkgver=0.4.1
pkgrel=2
pkgdesc='A command line tool for interacting with Nitrokey devices'
arch=(loong64 x86_64)
url=https://github.com/d-e-s-o/nitrocli
license=(GPL3)
depends=(
  gnupg
  libnitrokey.so
)
makedepends=(
  cargo
  git
)
optdepends=('bash-completion: Bash completion support')
_tag=8a8250f262100a95164a7b0ff8e1ea7d5c17e3a6
source=(git+https://github.com/d-e-s-o/nitrocli.git#tag=${_tag})
b2sums=(SKIP)

prepare() {
  cargo fetch \
    --locked \
    --manifest-path nitrocli/Cargo.toml
}

pkgver() {
  cd nitrocli
  git describe --tags | sed 's/^v//'
}

build() {
  export USE_SYSTEM_LIBNITROKEY=1
  cargo build \
    --release \
    --frozen \
    --manifest-path nitrocli/Cargo.toml
  cargo run \
    --release \
    --manifest-path nitrocli/Cargo.toml \
    --bin=shell-complete bash > nitrocli.bash
}

package() {
  cargo install \
    --frozen \
    --offline \
    --no-track \
    --path nitrocli \
    --bin nitrocli \
    --root "${pkgdir}"/usr
  install -Dm 644 nitrocli/doc/nitrocli.1 "${pkgdir}"/usr/share/man/man1/nitrocli.1
  install -Dm 644 nitrocli.bash "${pkgdir}"/usr/share/bash-completion/completions/nitrocli
}

# vim: ts=2 sw=2 et:
